import {
  IsString,
  IsEmail,
  IsNumber,
  IsOptional,
  IsArray,
  ValidateNested,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { CreateEventDto } from 'src/modules/event/dto/create-event.dto';
import { Type } from 'class-transformer';
import { PartialType } from '@nestjs/mapped-types';
import { IdObject } from 'src/common/utils/types';

export class CreatePlayerSignupDto {
  @ApiProperty({ description: ' 报名人员的唯一标识' })
  @IsString()
  @IsOptional()
  key?: string;

  @ApiProperty({ description: '选手姓名' })
  @IsString()
  name: string;

  @ApiPropertyOptional({ description: '选手电话号码' })
  @IsOptional()
  @IsString()
  phone?: string;

  @ApiPropertyOptional({ description: '选手电子邮箱' })
  @IsOptional()
  @IsEmail()
  email?: string;

  @ApiProperty({ description: '选手身份证号' })
  @IsString()
  idCard: string;

  @ApiPropertyOptional({ description: '选手年龄' })
  @IsNumber()
  age?: number;

  @ApiProperty({
    description: '选手性别',
    enum: ['male', 'female'],
    example: 'male',
  })
  @IsString()
  gender: 'male' | 'female';

  @ApiPropertyOptional({ description: '选手地址' })
  @IsOptional()
  @IsString()
  address?: string;

  // @ApiProperty({ description: '赛事ID' })
  // @IsNumber()
  // eventId: number;

  @ApiProperty({
    description: '报名的赛事ID',
    type: IdObject,
    isArray: true,
  })
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => IdObject) 
  events?: Array<IdObject>;

  @ApiPropertyOptional({ description: '团赛子比赛ID' })
  @IsOptional()
  @IsNumber()
  stageEventId?: number;

  @ApiPropertyOptional({ description: '选手所属组织/单位' })
  @IsOptional()
  @IsString()
  organization?: string;

  subPlayerSignups: { id: number }[];

  createBy?: number;

  createTime?: Date;

  updateBy?: number;

  updateTime?: Date;
}
